//
//  ViewController.m
//  ZSExtendScrollView-master
//
//  Created by safiri on 2018/8/6.
//  Copyright © 2018年 safiri. All rights reserved.
//

#import "ViewController.h"
#import "ZSLRPageScrollView.h"
#define ColorRGB(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0f]
#define randomColor ColorRGB(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256));

@interface ViewController ()<ZSLRPageScrollViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self exampleZSLRPageScrollView];
}

- (void)exampleZSLRPageScrollView {
    ZSLRPageScrollView *lrScrollView = [[ZSLRPageScrollView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 100)];
    lrScrollView.lrPageScrollViewDelegate = self;
    lrScrollView.pagingEnabled = YES;
    [self.view addSubview:lrScrollView];
    
    //添加一组view - addHorizontallyScrollViews
    NSMutableArray *array = [NSMutableArray arrayWithCapacity:4];
    for (NSInteger i = 0; i < 4; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)];
        label.backgroundColor = randomColor;
        label.text = [NSString stringWithFormat:@"%ld",(long)i];
        label.textAlignment = NSTextAlignmentCenter;
        [array addObject:label];
    }
    [lrScrollView addHorizontallyScrollViews:array];
    
    ZSLRPageScrollView *lrScrollView2 = [[ZSLRPageScrollView alloc] initWithFrame:CGRectMake(0, 220, self.view.frame.size.width, 100)];
    lrScrollView2.lrPageScrollViewDelegate = self;
    lrScrollView2.pagingEnabled = YES;
    [self.view addSubview:lrScrollView2];
    //一个一个添加view - addHorizontallyScrollView
    UILabel *label1 = [[UILabel alloc] init];
    label1.backgroundColor = randomColor;
    label1.text = @"1";
    label1.textAlignment = NSTextAlignmentCenter;
    [lrScrollView2 addHorizontallyScrollView:label1];
    UILabel *label2 = [[UILabel alloc] init];
    label2.backgroundColor = randomColor;
    label2.text = @"2";
    label2.textAlignment = NSTextAlignmentCenter;
    [lrScrollView2 addHorizontallyScrollView:label2];
    
    //先 addHorizontallyScrollViews 后 addHorizontallyScrollView
    ZSLRPageScrollView *lrScrollView3 = [[ZSLRPageScrollView alloc] initWithFrame:CGRectMake(0, 340, self.view.frame.size.width, 100)];
    lrScrollView3.lrPageScrollViewDelegate = self;
    lrScrollView3.pagingEnabled = YES;
    [self.view addSubview:lrScrollView3];
    
    NSMutableArray *array1 = [NSMutableArray arrayWithCapacity:4];
    for (NSInteger i = 0; i < 4; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)];
        label.backgroundColor = randomColor;
        label.text = [NSString stringWithFormat:@"%ld",(long)i];
        label.textAlignment = NSTextAlignmentCenter;
        [array1 addObject:label];
    }
    UILabel *label3 = [[UILabel alloc] init];
    label3.backgroundColor = randomColor;
    label3.text = @"哈哈哈";
    label3.textAlignment = NSTextAlignmentCenter;
    [lrScrollView3 addHorizontallyScrollViews:array1];
    [lrScrollView3 addHorizontallyScrollView:label3];
}

- (void)lrPageScrollView:(ZSLRPageScrollView *)scrollView changePage:(NSInteger)page {
    
}
- (void)lrPageScrollView:(ZSLRPageScrollView *)scrollView scrollRatio:(CGFloat)ratio {
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
